<template>
  <el-dialog
    v-model="visible"
    title="智能匹配房源"
    width="90%"
    :close-on-click-modal="false"
    destroy-on-close
  >
    <PropertyMatchList
      v-if="visible && leadId"
      :lead-id="leadId"
    />
  </el-dialog>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'
import PropertyMatchList from './PropertyMatchList.vue'

interface Props {
  modelValue: boolean
  leadId: number | null
}

interface Emits {
  (e: 'update:modelValue', value: boolean): void
}

const props = defineProps<Props>()
const emit = defineEmits<Emits>()

const visible = ref(props.modelValue)

watch(
  () => props.modelValue,
  (val) => {
    visible.value = val
  }
)

watch(visible, (val) => {
  emit('update:modelValue', val)
})
</script>
